<!--
 * @Author: 邱狮杰
 * @Date: 2021-09-05 12:34:32
 * @LastEditTime: 2021-09-05 12:51:46
 * @FilePath: /new-hope/src/page/message/windBlowsTheFragranceOfRice.vue
 * @Description: 描述
-->
<script lang="ts" setup>
import MessageBox from "/@/assets/images/userMessage.png";
import Title from "/@/assets/images/title/polarMessage.png";
import { ref } from "vue";
import { useBus } from "/@/hooks/bus";
import { useGo } from "/@/hooks/go";
import { withDefaults } from "vue";
import { convertToImage } from "/@/utils/toImage";
import html2canvas from "html2canvas";
const bus = useBus();
const [go] = useGo();
const game = ref(null);
const props = withDefaults(defineProps<{ titleImg: string }>(), {
  titleImg: Title,
});
async function save() {
  bus.emit("print", {});
  //   const canvas = await html2canvas(game.value as unknown as HTMLElement, {
  //     useCORS: true,
  //   });
  go({ name: "bestWishesSuccess" });
}
</script>
<template>
  <div ref="game" class="game">
    <div class="windBlowsTheFragranceOfRice">
      <div class="message">
        <img class="title" alt="message" :src="props.titleImg" />
        <div class="messageBox">
          <div class="userMessagebox">
            <div class="relativeBox">
              <img :src="MessageBox" />
              <textarea />
            </div>
          </div>
          <div class="longPressToSave">
            <div class="qrcode" @click="save"></div>
            <div class="msg">
              <span>长按保存</span>
              <span style="font-size: 11px; letter-spacing: 0px"
                >分享你的佳节祝福语</span
              >
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.game {
  height: 100%;
  width: 100%;
  background: url("../../assets/images/gameBkg.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.windBlowsTheFragranceOfRice {
  position: relative;
  height: 100%;
  width: 100%;
  background: url("../../assets/images/bkg/windBlowsTheFragranceOfRice.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.message {
  position: absolute;
  height: 100%;
  width: 100%;
  .title {
    position: absolute;
    top: 86px;
    left: 50%;
    transform: translateX(-50%);
    width: 336px;
  }
  .messageBox {
    position: relative;
    height: 100%;
    width: 100%;
    .longPressToSave {
      position: absolute;
      bottom: 20px;
      display: flex;
      // justify-content: center;
      align-items: center;
      .qrcode {
        width: 118px;
        height: 116px;
        background-color: #ffdb91;
        box-shadow: 0px 1px 2px 0px #8a050d;
        border: solid 1px #be1728;
        margin: {
          left: 32px;
          right: 13px;
        }
      }
      .msg {
        display: flex;
        flex-direction: column;
        align-self: flex-end;
        span {
          // width: 78px;
          font-size: 18px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 4px;
          font-weight: bold;
          color: #9b0b11;
          text-shadow: 0px 1px 2px 0px #ffd06f;
        }
      }
    }
    .userMessagebox {
      position: absolute;
      top: 212px;
      left: 50%;
      transform: translateX(-50%);
      width: 317px;
      height: 176px;
      .relativeBox {
        position: relative;
        img {
          height: 100%;
          width: 100%;
          object-fit: cover;
        }
        textarea {
          position: absolute;
          top: 42px;
          left: 50%;
          transform: translateX(-50%);
          height: 126px;
          width: 90%;
          outline: none;
          border: none;
          background: transparent;
          font-size: 16px;
          font-weight: bold;
          font-stretch: normal;
          // line-height: 34px;
          letter-spacing: 2px;
          color: #bd010c;
          text-align: center;
        }
      }
    }
  }
}
</style>
